<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Linux," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;磁盘配合其实就是给每个用户分配一定的磁盘额度，只允许他使用这个额度范围内的磁盘空间。在linux系统中，是多用户多任务的环境，所以会有很多人共用一个磁盘的情况。针对每个用户去限定一定量的磁盘空间是有必要的，这样才显得公平。随着硬件成本的降低，服务器上的磁盘资源似乎不再刻意的去限制了，所以磁盘配额也就可有">
<meta name="keywords" content="Linux">
<meta property="og:type" content="article">
<meta property="og:title" content="磁盘配额">
<meta property="og:url" content="https://hcldirgit.github.io/2017/09/03/1. Linux 基础/27.磁盘配额/index.html">
<meta property="og:site_name" content="失落的乐章">
<meta property="og:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;磁盘配合其实就是给每个用户分配一定的磁盘额度，只允许他使用这个额度范围内的磁盘空间。在linux系统中，是多用户多任务的环境，所以会有很多人共用一个磁盘的情况。针对每个用户去限定一定量的磁盘空间是有必要的，这样才显得公平。随着硬件成本的降低，服务器上的磁盘资源似乎不再刻意的去限制了，所以磁盘配额也就可有">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2017-09-01T08:28:07.245Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="磁盘配额">
<meta name="twitter:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;磁盘配合其实就是给每个用户分配一定的磁盘额度，只允许他使用这个额度范围内的磁盘空间。在linux系统中，是多用户多任务的环境，所以会有很多人共用一个磁盘的情况。针对每个用户去限定一定量的磁盘空间是有必要的，这样才显得公平。随着硬件成本的降低，服务器上的磁盘资源似乎不再刻意的去限制了，所以磁盘配额也就可有">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://hcldirgit.github.io/2017/09/03/1. Linux 基础/27.磁盘配额/"/>





  <title>磁盘配额 | 失落的乐章</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', '85*****1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?87980c**************99ec5e26fb5";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>











  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">失落的乐章</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">技术面前，永远都是学生。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-message">
          <a href="/message" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-external-link"></i> <br />
            
            留言
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://hcldirgit.github.io/2017/09/03/1. Linux 基础/27.磁盘配额/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="失落的乐章">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/0.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="失落的乐章">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">磁盘配额</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-09-03T01:55:11+08:00">
                2017-09-03
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;磁盘配合其实就是给每个用户分配一定的磁盘额度，只允许他使用这个额度范围内的磁盘空间。在linux系统中，是多用户多任务的环境，所以会有很多人共用一个磁盘的情况。针对每个用户去限定一定量的磁盘空间是有必要的，这样才显得公平。随着硬件成本的降低，服务器上的磁盘资源似乎不再刻意的去限制了，所以磁盘配额也就可有可无了，但是也需要了解一下这部分内容，用到时必须会操作。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在linux中，用来管理磁盘配额的东西就是quota了。如果linux上没有quota，则需要安装这个软件包 quota-3.13-5.el5.RPM （其实版本是多少无所谓了，关键是这个软件包）。quota在实际应用中是针对整个分区进行限制的。比如，如果我们限制了/dev/sdb1这个分区，而/dev/sdb1 是挂载在/home 目录下的，那么/home 所有目录都会受到限制。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;quota 这个模块主要分为quota 、quotacheck 、quotaoff 、quotaon 、quotastats 、edquota 、setquota 、warnquota 、repquota这几个命令，下面就分别介绍这些命令。</p>
<h2 id="命令-quota"><a href="#命令-quota" class="headerlink" title="命令 : quota"></a>命令 : quota</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;“quota” 用来显示某个组或者某个使用者的限额。</p>
<h3 id="语法："><a href="#语法：" class="headerlink" title="语法："></a>语法：</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">quota [-guvs] [user,group]</div></pre></td></tr></table></figure>
<h3 id="基本参数"><a href="#基本参数" class="headerlink" title="基本参数"></a>基本参数</h3><ul>
<li>-g 显示某个组的限额</li>
<li>-u 显示某个用户的限额</li>
<li>-v 显示的意思</li>
<li>-s 选择inod或硬盘空间来显示</li>
</ul>
<h2 id="命令-quotacheck"><a href="#命令-quotacheck" class="headerlink" title="命令 : quotacheck"></a>命令 : quotacheck</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;“quotacheck” 用来扫描某一个磁盘的quota空间。</p>
<h3 id="语法：-1"><a href="#语法：-1" class="headerlink" title="语法："></a>语法：</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">quotacheck [-auvg] /path</div></pre></td></tr></table></figure>
<h3 id="基本参数-1"><a href="#基本参数-1" class="headerlink" title="基本参数"></a>基本参数</h3><ul>
<li>-a 扫描所有已经mount的具有quota支持的磁盘</li>
<li>-u 扫描某个使用者的文件以及目录</li>
<li>-g 扫描某个组的文件以及目录</li>
<li>-v 显示扫描过程</li>
<li>-m 强制进行扫描</li>
</ul>
<h2 id="命令-edquota"><a href="#命令-edquota" class="headerlink" title="命令 : edquota"></a>命令 : edquota</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;“edquota” 用来编辑某个用户或者组的quota值。</p>
<h3 id="语法：-2"><a href="#语法：-2" class="headerlink" title="语法："></a>语法：</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">edquota [-u user] [-g group] [-t]</div></pre></td></tr></table></figure>
<h3 id="基本参数-2"><a href="#基本参数-2" class="headerlink" title="基本参数"></a>基本参数</h3><ul>
<li>-u 编辑某个用户的quota</li>
<li>-g 编辑某个组的quota</li>
<li>-t 编辑宽限时间</li>
<li>-p 拷贝某个用户或组的quota到另一个用户或组</li>
</ul>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;当运行 <code>edquota -u user</code> 时，系统会打开一个文件，你会看到这个文件中有7列，它们分别代表的含义是：</p>
<ul>
<li>“Filesystem” 磁盘分区，如/dev/sdb5</li>
<li>“blocks” 当前用户在当前的Filesystem中所占用的磁盘容量，单位是Kb。该值请不要修改。</li>
<li>“soft/hard” 当前用户在该Filesystem内的quota值，soft指的是最低限额，可以超过这个值，但必须要在宽限时间内将磁盘容量降低到这个值以下。hard指的是最高限额，即不能超过这个值。当用户的磁盘使用量高于soft值时，系统会警告用户，提示其要在宽限时间内把使用空间降低到soft值之下。</li>
<li>“inodes” 目前使用掉的inode的状态，不用修改。</li>
</ul>
<h2 id="命令-quotaon"><a href="#命令-quotaon" class="headerlink" title="命令 : quotaon"></a>命令 : quotaon</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;“quotaon” 用来启动quota，在编辑好quota后，需要启动才能是quota生效</p>
<h3 id="语法：-3"><a href="#语法：-3" class="headerlink" title="语法："></a>语法：</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">quotaon [-a] [-uvg directory]</div></pre></td></tr></table></figure>
<h3 id="基本参数-3"><a href="#基本参数-3" class="headerlink" title="基本参数"></a>基本参数</h3><ul>
<li>-a 全部设定的quota启动</li>
<li>-u 启动某个用户的quota</li>
<li>-g 启动某个组的quota</li>
<li>-s 显示相关信息</li>
</ul>
<h2 id="命令-quotaoff"><a href="#命令-quotaoff" class="headerlink" title="命令 : quotaoff"></a>命令 : quotaoff</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;“quotaoff” 用来关闭quota, 该命令常用只有一种情况 quotaoff -a 关闭全部的quota.</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;以上讲了很多quota的相关命令，那么接下来阿铭教你如何在实践应用中去做这个磁盘配额。整个执行过程如下：</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;首先先确认一下，/home目录是不是单独的挂载在一个分区下，用df 查看即可。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">文件系统                 1K-块      已用      可用 已用% 挂载点</div><div class="line">/dev/sda3             14347632   1899376  11719424  14% /</div><div class="line">tmpfs                   163308         0    163308   0% /dev/shm</div><div class="line">/dev/sda1                99150     26808     67222  29% /boot</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;上例linux系统中，/home并没有单独占用一个分区。所以需要把/home目录挂载在一个单独的分区下，因为quota是针对分区来限额的。下面把 /dev/sdb5 挂载到/home 目录下， 编辑 /etc/fstab 把刚才添加的那行修改为：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">UUID=c61117ca-9176-4d0b-be4d-1b0f434359a7              /home                 ext4    defaults        0 0</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;保存 /etc/fstab 后，运行 mount -a 命令挂载全部的分区。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># mount -a</span></div><div class="line">[root@localhost ~]<span class="comment"># df -h</span></div><div class="line">文件系统              容量  已用  可用 已用%% 挂载点</div><div class="line">/dev/sda3              14G  1.9G   12G  14% /</div><div class="line">tmpfs                 160M     0  160M   0% /dev/shm</div><div class="line">/dev/sda1              97M   27M   66M  29% /boot</div><div class="line">/dev/sdb5             989M   18M  921M   2% /home</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;此时的 /home 为一个单独分区了。</p>
<ol>
<li>建立测试账户<br>首先建立一个test用户，则同时建立了一个test组。其中uid和gid都为511 ，然后又建立一个test1账号，使其加入test组，查看/etc/passwd文件发现test和test1用户的gid都为511.</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># useradd test</span></div><div class="line">[root@localhost ~]<span class="comment"># grep test /etc/passwd</span></div><div class="line"><span class="built_in">test</span>:x:511:511::/home/<span class="built_in">test</span>:/bin/bash</div><div class="line">[root@localhost ~]<span class="comment"># useradd -g 511 test1</span></div><div class="line">[root@localhost ~]<span class="comment"># grep test1 /etc/passwd</span></div><div class="line">test1:x:512:511::/home/test1:/bin/bash</div></pre></td></tr></table></figure>
<ol>
<li>打开磁盘的quota功能<br>默认linux并没有对任何分区做quota的支持，所以需要我们手动打开磁盘的quota功能，你是否记得，在前面内容中分析/etc/fstab文件的第四列时讲过这个quota选项（usrquota, grpquota），没错，要想打开这个磁盘的quota支持就是需要修改这个第四列的。用vi编辑/etc/fstab 编辑刚才加的那一行，如下:</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">UUID=c61117ca-9176-4d0b-be4d-1b0f434359a7     /home        ext4    defaults,usrquota,grpquota     0 0</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;保存 /etc/fstab 后，重新挂载/home分区。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># umount /home/</span></div><div class="line">[root@localhost ~]<span class="comment"># mount -a</span></div><div class="line">[root@localhost ~]<span class="comment"># mount</span></div><div class="line">/dev/sda3 on / <span class="built_in">type</span> ext4 (rw)</div><div class="line">proc on /proc <span class="built_in">type</span> proc (rw)</div><div class="line">sysfs on /sys <span class="built_in">type</span> sysfs (rw)</div><div class="line">devpts on /dev/pts <span class="built_in">type</span> devpts (rw,gid=5,mode=620)</div><div class="line">tmpfs on /dev/shm <span class="built_in">type</span> tmpfs (rw)</div><div class="line">/dev/sda1 on /boot <span class="built_in">type</span> ext4 (rw)</div><div class="line">none on /proc/sys/fs/binfmt_misc <span class="built_in">type</span> binfmt_misc (rw)</div><div class="line">/dev/sdb5 on /home <span class="built_in">type</span> ext4 (rw,usrquota,grpquota)</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;使用 mount 命令可以查看到 /home 分区已经加上了 “usrquota,grpquota” 两个配额相关的参数。</p>
<ol>
<li>扫描磁盘的使用者使用状况，并产生重要的aquota.group与aquota.user<br>这一步就需要用到quotacheck了，aquota.group与aqouta.user分别是组以及用户磁盘配额需要的配置文件。如果没有这两个文件，则磁盘配额是不会生效的。</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># quotacheck -augv</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;可能会有一些错误信息，不要管它。看一看/home分区下是否多了两个文件(aquota.group, aquota.user)</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># ll /home/</span></div><div class="line">总用量 44</div><div class="line">-rw------- 1 root  root  7168 5月  12 02:07 aquota.group</div><div class="line">-rw------- 1 root  root  8192 5月  12 02:07 aquota.user</div><div class="line">drwxr-xr-x 2 root  root  4096 5月  12 00:11 dir1</div><div class="line">drwx------ 2 root  root 16384 5月  11 23:18 lost+found</div><div class="line">drwx------ 3 <span class="built_in">test</span>  <span class="built_in">test</span>  4096 5月  12 01:59 <span class="built_in">test</span></div><div class="line">drwx------ 3 test1 <span class="built_in">test</span>  4096 5月  12 02:00 test1</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果有了，则可以进入下一步了。</p>
<ol>
<li>启动quota配额</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># quotaon -av</span></div><div class="line">/dev/sdb5 [/home]: group quotas turned on</div><div class="line">/dev/sdb5 [/home]: user quotas turned on</div></pre></td></tr></table></figure>
<ol>
<li>编辑用户磁盘配额<br>先来设定test账户的配额，然后直接把test的配额拷贝给test1即可。这里就需要用到edquota了。</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># edquota -u test</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;将下面内容</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">/dev/sdb5                        20          0          0          5        0        0</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;修改为：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">/dev/sdb5                        20          20000          30000          5        0        0</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;其中单位是Kb，所以soft 值大约为20Mb，hard值为30Mb，保存这个文件，保存的方式跟vi一个文件的方式一样的。下面将test的配额复制给test1.</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># edquota -p test test1</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;下面继续设定宽限时间：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># edquota -t</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;将7days 改为 1days</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">/dev/sdb5                     1days                  1days</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;下面查看一下test以及test1用户的配额吧。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># quota -uv test test1</span></div><div class="line">Disk quotas <span class="keyword">for</span> user <span class="built_in">test</span> (uid 511):</div><div class="line">     Filesystem  blocks   quota   <span class="built_in">limit</span>   grace   files   quota   <span class="built_in">limit</span>   grace</div><div class="line">      /dev/sdb5      20   20000   30000               5       0       0</div><div class="line">Disk quotas <span class="keyword">for</span> user test1 (uid 512):</div><div class="line">     Filesystem  blocks   quota   <span class="built_in">limit</span>   grace   files   quota   <span class="built_in">limit</span>   grace</div><div class="line">      /dev/sdb5      20   20000   30000               5       0       0</div></pre></td></tr></table></figure>
<ol>
<li>编辑组磁盘配额</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># edquota -g test</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;修改为：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">/dev/sdb5                        40          40000          50000         10        0        0</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;设定组test的soft配额值为40M，hard值为50M。下面查看组test的配额。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># quota -gv test</span></div><div class="line">Disk quotas <span class="keyword">for</span> group <span class="built_in">test</span> (gid 511):</div><div class="line">     Filesystem  blocks   quota   <span class="built_in">limit</span>   grace   files   quota   <span class="built_in">limit</span>   grace</div><div class="line">      /dev/sdb5      40   40000   50000              10       0       0</div></pre></td></tr></table></figure>
<ol>
<li>设定开机启动<br>前面已经讲到启动磁盘配额的命令是 quotaon -aug 所以要想开机启动，只需将这条命令加入到 /etc/rc.d/rc.local文件即可。</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># echo "quotaon -aug" &gt;&gt; /etc/rc.d/rc.local</span></div></pre></td></tr></table></figure>
      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Linux/" rel="tag"># Linux</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/09/03/1. Linux 基础/20. Linux如何分大于2T的磁盘分区/" rel="next" title="Linux如何分大于2T的磁盘分区">
                <i class="fa fa-chevron-left"></i> Linux如何分大于2T的磁盘分区
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/09/03/1. Linux 基础/49. Linux下调整时区和时间的方法/" rel="prev" title="Linux下调整时区和时间的方法">
                Linux下调整时区和时间的方法 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/0.png"
               alt="失落的乐章" />
          <p class="site-author-name" itemprop="name">失落的乐章</p>
           
              <p class="site-description motion-element" itemprop="description">失落的乐章的Blog</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/">
                <span class="site-state-item-count">627</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">38</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/hcldirgit" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#命令-quota"><span class="nav-number">1.</span> <span class="nav-text">命令 : quota</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#语法："><span class="nav-number">1.1.</span> <span class="nav-text">语法：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#基本参数"><span class="nav-number">1.2.</span> <span class="nav-text">基本参数</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#命令-quotacheck"><span class="nav-number">2.</span> <span class="nav-text">命令 : quotacheck</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#语法：-1"><span class="nav-number">2.1.</span> <span class="nav-text">语法：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#基本参数-1"><span class="nav-number">2.2.</span> <span class="nav-text">基本参数</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#命令-edquota"><span class="nav-number">3.</span> <span class="nav-text">命令 : edquota</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#语法：-2"><span class="nav-number">3.1.</span> <span class="nav-text">语法：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#基本参数-2"><span class="nav-number">3.2.</span> <span class="nav-text">基本参数</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#命令-quotaon"><span class="nav-number">4.</span> <span class="nav-text">命令 : quotaon</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#语法：-3"><span class="nav-number">4.1.</span> <span class="nav-text">语法：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#基本参数-3"><span class="nav-number">4.2.</span> <span class="nav-text">基本参数</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#命令-quotaoff"><span class="nav-number">5.</span> <span class="nav-text">命令 : quotaoff</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">失落的乐章</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
